/************************************************************************
 * <br>
 * <ul>
 * <li>版权所有：唐山弘川科技有限公司 2009－2020</li>
 * <li>创建日期：2009-8-10</li>
 * <li>初始作者：刘川</li>
 * </ul>
 * <ul>
 * <b>修订历史</b>
 * <li>1、</li>
 * </ul>
 ***********************************************************************/
package com.hy.enterprise.framework.persistence.domain.query ;

import com.hy.enterprise.framework.persistence.domain.query.internal.AliasFactory;
import com.hy.enterprise.framework.persistence.domain.query.internal.LibraPersistentObjectFactory;
import com.hy.enterprise.framework.persistence.domain.query.internal.managedobjects.LibraManagedObject;

/**
 * <ul>
 * <li>设计作者：刘川</li>
 * <li>设计日期：2009-8-10</li>
 * <li>设计时间：下午03:37:24</li>
 * <li>设计目的：</li>
 * </ul>
 * <ul>
 * <b>修订历史</b>
 * <li>1、</li>
 * </ul>
 */
public class Parameters
{
	private static LibraPersistentObjectFactory	factory	=
	                                                      LibraPersistentObjectFactory.INSTANCE ;

	public static < T > T param (
	                              final int num ,
	                              Class < T > clazz )
	{
		T object =
		           Parameters.factory
		                             .makeNew ( clazz ) ;
		AliasFactory
		            .remember (
		                        object ,
		                        new LibraManagedObject ( )
		                        {
			                        @ Override
			                        public String getTargetRepresentation ( )
			                        {
				                        return "?"
				                               + num ;
			                        }
		                        } ) ;
		return object ;
	}

	public static < T > T param (
	                              final String name ,
	                              Class < T > clazz )
	{
		T object =
		           Parameters.factory
		                             .makeNew ( clazz ) ;
		AliasFactory
		            .remember (
		                        object ,
		                        new LibraManagedObject ( )
		                        {
			                        @ Override
			                        public String getTargetRepresentation ( )
			                        {
				                        return ":"
				                               + name ;
			                        }
		                        } ) ;
		return object ;
	}

	/**
	 * 构造函数
	 */
	private Parameters ( )
	{
		super ( ) ;
	}
}
